Playing Sounds From JavaScript

Category: Geeks r Us

Post 1 by TylerK (This site is so "educational") on Wednesday, 27-Oct-2010 20:41:33

Hey all,

Can anybody tell me a browser-neutral way to play sounds from client-side JavaScript? The sound files are in the same directory as the web page. I tried using <embed> and <noembed> in document.write statements, but that ad-hoc insertion of HTML didn't work.

Any help would be appreciated.

Tyler

Post 2 by LeoGuardian (You mean there is something outside of this room with my computer in it?) on Thursday, 28-Oct-2010 0:11:44

Entered it before but missed anyway i've a suggestion:
www.boutell.com/newfaq/creating/scriptsound.html
And no I haven't used it but it's free and appears to use Flash indirectly - the player never shows on your user's page. This way you could use the onload and onunload events.
I haven't dug further, I'm drinkin' beers and watching the game lol

Post 3 by malthe (Pimply-Faced Youth) on Thursday, 28-Oct-2010 2:32:53

I believe flash is the only cross browser way of doing js, thoughI'm not sure. Check the zone source code?

Post 4 by LeoGuardian (You mean there is something outside of this room with my computer in it?) on Thursday, 28-Oct-2010 10:56:17

And I realize you want browser-agnosticism, who doesn't? We all can appreciate that one.
The problem you'll find is that there is no such thing as a browser-agnostic plugin for sound. And yes, I just saw you take your hat off to html 5 ... for so many reasons ... <grin>